package com.etc.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.etc.entity.Users;

//xx/api/listUser
@Controller
@RequestMapping("api")
public class UsersController {
	@Resource(name = "u")
	private Users u;

	/**
	 * 得到用户信息 ，用户登录了才可以,进行拦截
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "listUser")
	public String getUser(Model model) {
		model.addAttribute("u", u);
		return "users";
	}
	
	//用户登录的请求
	@RequestMapping(value = "login")
	public String login(Model model,String name,HttpSession session) {
		//不拦截，从视图提交用户信息过来
		session.setAttribute("name", name);
		return "users";
	}
}
